package de.Objects;

import javax.media.j3d.Appearance;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.ImageComponent2D;
import javax.media.j3d.Material;
import javax.media.j3d.PolygonAttributes;
import javax.media.j3d.TexCoordGeneration;
import javax.media.j3d.Texture;
import javax.media.j3d.Texture2D;
import javax.media.j3d.TextureAttributes;
import javax.media.j3d.TextureUnitState;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Vector3f;

import com.sun.j3d.utils.geometry.Box;
import com.sun.j3d.utils.geometry.Primitive;
import com.sun.j3d.utils.geometry.Sphere;
import com.sun.j3d.utils.image.TextureLoader;

public class createBubbles extends BranchGroup {

	BranchGroup root = new BranchGroup();
	Appearance apperBubbles = new Appearance();
	Appearance apperOne = new Appearance();
	Appearance apperTwo = new Appearance();
	Appearance apperSwitch = new Appearance();
	int primflags;
	String textureLightMapName = "textures/LightMap.jpg";

	public createBubbles() {
		primflags = Primitive.GENERATE_NORMALS
				+ Primitive.GENERATE_TEXTURE_COORDS;

		createAppearances();
		createSwitch();
		createOuterBubbles();
		createMiddleButtons();
		createInnerButtons();
		createOut1();
		createOut2();

		super.addChild(root);
	}

	public void createAppearances() {
		Color3f ambient = new Color3f(0.0f, 0.0f, 0.0f);
		Color3f emissive = new Color3f(0.3f, 0.3f, 0.3f);
		Color3f diffuse = new Color3f(0.2f, 0.2f, 0.2f);
		Color3f specular = new Color3f(0.8f, 0.8f, 0.8f);
		Material material = new Material(ambient, emissive, diffuse, specular,
				100.0f);
		material.setLightingEnable(true);

		// //////////Bubbles
		TextureLoader loaderBubbles = new TextureLoader("textures/s2.jpg", null);
		ImageComponent2D imageBubbles = loaderBubbles.getImage();
		if (imageBubbles == null) {
			System.out.println("failed loading texture");
		} else {
			Texture2D textTureBubbles = new Texture2D(Texture.BASE_LEVEL,
					Texture.RGBA, imageBubbles.getWidth(),
					imageBubbles.getHeight());
			textTureBubbles.setImage(0, imageBubbles);
			apperBubbles.setTexture(textTureBubbles);

			TextureAttributes texAttrBubbles = new TextureAttributes();
			texAttrBubbles.setTextureMode(TextureAttributes.MODULATE);
			apperBubbles.setTextureAttributes(texAttrBubbles);
			apperBubbles.setMaterial(material);
		}

		// //////// Side 1
		TextureLoader loaderOne = new TextureLoader("textures/Gold.jpg", null);
		ImageComponent2D imageOne = loaderOne.getImage();
		if (imageOne == null) {
			System.out.println("failed loading texture");
		} else {
			Texture2D textTureOne = new Texture2D(Texture.BASE_LEVEL,
					Texture.RGBA, imageOne.getWidth(), imageOne.getHeight());
			textTureOne.setImage(0, imageOne);
			apperOne.setTexture(textTureOne);

			TextureAttributes texAttrOne = new TextureAttributes();
			texAttrOne.setTextureMode(TextureAttributes.MODULATE);
			apperOne.setTextureAttributes(texAttrOne);
			apperOne.setMaterial(material);
		}

		// //////// Side 2
		TextureLoader loaderTwo = new TextureLoader("textures/1.jpg", null);
		ImageComponent2D imageTwo = loaderTwo.getImage();
		if (imageTwo == null) {
			System.out.println("failed loading texture");
		} else {
			Texture2D textTureTwo = new Texture2D(Texture.BASE_LEVEL,
					Texture.RGBA, imageTwo.getWidth(), imageTwo.getHeight());
			textTureTwo.setImage(0, imageTwo);
			apperTwo.setTexture(textTureTwo);

			TextureAttributes texAttrTwo = new TextureAttributes();
			texAttrTwo.setTextureMode(TextureAttributes.MODULATE);
			apperTwo.setTextureAttributes(texAttrTwo);
			apperTwo.setMaterial(material);
		}

		// // //////// VIEW SWITCHES
		// TextureLoader loaderSwitch = new
		// TextureLoader("textures/Marmor_1.jpg",
		// null);
		// ImageComponent2D imageSwitch = loaderSwitch.getImage();
		// if (imageSwitch == null) {
		// System.out.println("failed loading texture");
		// } else {
		// Texture2D textTureSwitch = new Texture2D(Texture.BASE_LEVEL,
		// Texture.RGBA, imageSwitch.getWidth(),
		// imageSwitch.getHeight());
		// textTureSwitch.setImage(0, imageSwitch);
		// apperSwitch.setTexture(textTureSwitch);
		//
		// TextureAttributes texAttrSwitch = new TextureAttributes();
		// texAttrSwitch.setTextureMode(TextureAttributes.MODULATE);
		// apperSwitch.setTextureAttributes(texAttrSwitch);
		// apperSwitch.setMaterial(material);
		// }

		apperSwitch = createAppearance("textures/snow1G.jpg",
				"textures/snow2.jpg");

	}

	public void createOuterBubbles() {
		Transform3D translation1 = new Transform3D();
		translation1.setTranslation(new Vector3f(3.5f, 0.4f, 0.0f));
		TransformGroup tg1 = new TransformGroup(translation1);
		root.addChild(tg1);
		Sphere O1 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg1.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O1.setUserData(translation1);
		tg1.addChild(O1);

		Transform3D translation2 = new Transform3D();
		translation2.setTranslation(new Vector3f(-3.5f, 0.4f, 0.0f));
		TransformGroup tg2 = new TransformGroup(translation2);
		root.addChild(tg2);
		Sphere O2 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg2.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O2.setUserData(translation2);
		tg2.addChild(O2);

		Transform3D translation3 = new Transform3D();
		translation3.setTranslation(new Vector3f(-3.5f, 0.4f, 3.5f));
		TransformGroup tg3 = new TransformGroup(translation3);
		root.addChild(tg3);
		Sphere O3 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg3.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O3.setUserData(translation3);
		tg3.addChild(O3);

		Transform3D translation4 = new Transform3D();
		translation4.setTranslation(new Vector3f(-3.5f, 0.4f, -3.5f));
		TransformGroup tg4 = new TransformGroup(translation4);
		root.addChild(tg4);
		Sphere O4 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg4.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O4.setUserData(translation4);
		tg4.addChild(O4);

		Transform3D translation5 = new Transform3D();
		translation5.setTranslation(new Vector3f(3.5f, 0.4f, -3.5f));
		TransformGroup tg5 = new TransformGroup(translation5);
		root.addChild(tg5);
		Sphere O5 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg5.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O5.setUserData(translation5);
		tg5.addChild(O5);

		Transform3D translation6 = new Transform3D();
		translation6.setTranslation(new Vector3f(3.5f, 0.4f, 3.5f));
		TransformGroup tg6 = new TransformGroup(translation6);
		root.addChild(tg6);
		Sphere O6 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg6.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O6.setUserData(translation6);
		tg6.addChild(O6);

		Transform3D translation7 = new Transform3D();
		translation7.setTranslation(new Vector3f(0.0f, 0.4f, 3.5f));
		TransformGroup tg7 = new TransformGroup(translation7);
		root.addChild(tg7);
		Sphere O7 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg7.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O7.setUserData(translation7);
		tg7.addChild(O7);

		Transform3D translation8 = new Transform3D();
		translation8.setTranslation(new Vector3f(0.0f, 0.4f, -3.5f));
		TransformGroup tg8 = new TransformGroup(translation8);
		root.addChild(tg8);
		Sphere O8 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg8.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O8.setUserData(translation8);
		tg8.addChild(O8);
	}

	public void createMiddleButtons() {
		Transform3D translation1 = new Transform3D();
		translation1.setTranslation(new Vector3f(2.5f, 0.4f, 0.0f));
		TransformGroup tg1 = new TransformGroup(translation1);
		root.addChild(tg1);
		Sphere O1 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg1.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O1.setUserData(translation1);
		tg1.addChild(O1);

		Transform3D translation2 = new Transform3D();
		translation2.setTranslation(new Vector3f(-2.5f, 0.4f, 0.0f));
		TransformGroup tg2 = new TransformGroup(translation2);
		root.addChild(tg2);
		Sphere O2 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg2.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O2.setUserData(translation2);
		tg2.addChild(O2);

		Transform3D translation3 = new Transform3D();
		translation3.setTranslation(new Vector3f(-2.5f, 0.4f, 2.5f));
		TransformGroup tg3 = new TransformGroup(translation3);
		root.addChild(tg3);
		Sphere O3 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg3.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O3.setUserData(translation3);
		tg3.addChild(O3);

		Transform3D translation4 = new Transform3D();
		translation4.setTranslation(new Vector3f(-2.5f, 0.4f, -2.5f));
		TransformGroup tg4 = new TransformGroup(translation4);
		root.addChild(tg4);
		Sphere O4 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg4.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O4.setUserData(translation4);
		tg4.addChild(O4);

		Transform3D translation5 = new Transform3D();
		translation5.setTranslation(new Vector3f(2.5f, 0.4f, -2.5f));
		TransformGroup tg5 = new TransformGroup(translation5);
		root.addChild(tg5);
		Sphere O5 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg5.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O5.setUserData(translation5);
		tg5.addChild(O5);

		Transform3D translation6 = new Transform3D();
		translation6.setTranslation(new Vector3f(2.5f, 0.4f, 2.5f));
		TransformGroup tg6 = new TransformGroup(translation6);
		root.addChild(tg6);
		Sphere O6 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg6.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O6.setUserData(translation6);
		tg6.addChild(O6);

		Transform3D translation7 = new Transform3D();
		translation7.setTranslation(new Vector3f(0.0f, 0.4f, 2.5f));
		TransformGroup tg7 = new TransformGroup(translation7);
		root.addChild(tg7);
		Sphere O7 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg7.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O7.setUserData(translation7);
		tg7.addChild(O7);

		Transform3D translation8 = new Transform3D();
		translation8.setTranslation(new Vector3f(0.0f, 0.4f, -2.5f));
		TransformGroup tg8 = new TransformGroup(translation8);
		root.addChild(tg8);
		Sphere O8 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg8.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O8.setUserData(translation8);
		tg8.addChild(O8);
	}

	public void createInnerButtons() {
		Transform3D translation1 = new Transform3D();
		translation1.setTranslation(new Vector3f(1.5f, 0.4f, 0.0f));
		TransformGroup tg1 = new TransformGroup(translation1);
		root.addChild(tg1);
		Sphere O1 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg1.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O1.setUserData(translation1);
		tg1.addChild(O1);

		Transform3D translation2 = new Transform3D();
		translation2.setTranslation(new Vector3f(-1.5f, 0.4f, 0.0f));
		TransformGroup tg2 = new TransformGroup(translation2);
		root.addChild(tg2);
		Sphere O2 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg2.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O2.setUserData(translation2);
		tg2.addChild(O2);

		Transform3D translation3 = new Transform3D();
		translation3.setTranslation(new Vector3f(-1.5f, 0.4f, 1.5f));
		TransformGroup tg3 = new TransformGroup(translation3);
		root.addChild(tg3);
		Sphere O3 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg3.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O3.setUserData(translation3);
		tg3.addChild(O3);

		Transform3D translation4 = new Transform3D();
		translation4.setTranslation(new Vector3f(-1.5f, 0.4f, -1.5f));
		TransformGroup tg4 = new TransformGroup(translation4);
		root.addChild(tg4);
		Sphere O4 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg4.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O4.setUserData(translation4);
		tg4.addChild(O4);

		Transform3D translation5 = new Transform3D();
		translation5.setTranslation(new Vector3f(1.5f, 0.4f, -1.5f));
		TransformGroup tg5 = new TransformGroup(translation5);
		root.addChild(tg5);
		Sphere O5 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg5.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O5.setUserData(translation5);
		tg5.addChild(O5);

		Transform3D translation6 = new Transform3D();
		translation6.setTranslation(new Vector3f(1.5f, 0.4f, 1.5f));
		TransformGroup tg6 = new TransformGroup(translation6);
		root.addChild(tg6);
		Sphere O6 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg6.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O6.setUserData(translation6);
		tg6.addChild(O6);

		Transform3D translation7 = new Transform3D();
		translation7.setTranslation(new Vector3f(0.0f, 0.4f, 1.5f));
		TransformGroup tg7 = new TransformGroup(translation7);
		root.addChild(tg7);
		Sphere O7 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg7.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O7.setUserData(translation7);
		tg7.addChild(O7);

		Transform3D translation8 = new Transform3D();
		translation8.setTranslation(new Vector3f(0.0f, 0.4f, -1.5f));
		TransformGroup tg8 = new TransformGroup(translation8);
		root.addChild(tg8);
		Sphere O8 = new Sphere(0.3f, primflags, 30, apperBubbles);
		tg8.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		O8.setUserData(translation8);
		tg8.addChild(O8);
	}

	public void createOut1() {
		Transform3D translation1 = new Transform3D();
		translation1.setTranslation(new Vector3f(0.0f, -0.1f, -5.5f));
		TransformGroup tg1 = new TransformGroup(translation1);
		root.addChild(tg1);
		Box out1 = new Box(0.4f, 0.1f, 0.4f, primflags, apperOne);
		tg1.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out1.setUserData(translation1);
		tg1.addChild(out1);

		Transform3D translation2 = new Transform3D();
		translation2.setTranslation(new Vector3f(1.0f, -0.1f, -5.5f));
		TransformGroup tg2 = new TransformGroup(translation2);
		root.addChild(tg2);
		Box out2 = new Box(0.4f, 0.1f, 0.4f, primflags, apperOne);
		tg2.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out2.setUserData(translation2);
		tg2.addChild(out2);

		Transform3D translation3 = new Transform3D();
		translation3.setTranslation(new Vector3f(-1.0f, -0.1f, -5.5f));
		TransformGroup tg3 = new TransformGroup(translation3);
		root.addChild(tg3);
		Box out3 = new Box(0.4f, 0.1f, 0.4f, primflags, apperOne);
		tg3.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out3.setUserData(translation3);
		tg3.addChild(out3);

		Transform3D translation4 = new Transform3D();
		translation4.setTranslation(new Vector3f(2.0f, -0.1f, -5.5f));
		TransformGroup tg4 = new TransformGroup(translation4);
		root.addChild(tg4);
		Box out4 = new Box(0.4f, 0.1f, 0.4f, primflags, apperOne);
		tg4.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out4.setUserData(translation4);
		tg4.addChild(out4);

		Transform3D translation5 = new Transform3D();
		translation5.setTranslation(new Vector3f(-2.0f, -0.1f, -5.5f));
		TransformGroup tg5 = new TransformGroup(translation5);
		root.addChild(tg5);
		Box out5 = new Box(0.4f, 0.1f, 0.4f, primflags, apperOne);
		tg5.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out5.setUserData(translation5);
		tg5.addChild(out5);

		Transform3D translation6 = new Transform3D();
		translation6.setTranslation(new Vector3f(3.0f, -0.1f, -5.5f));
		TransformGroup tg6 = new TransformGroup(translation6);
		root.addChild(tg6);
		Box out6 = new Box(0.4f, 0.1f, 0.4f, primflags, apperOne);
		tg6.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out6.setUserData(translation6);
		tg6.addChild(out6);

		Transform3D translation7 = new Transform3D();
		translation7.setTranslation(new Vector3f(-3.0f, -0.1f, -5.5f));
		TransformGroup tg7 = new TransformGroup(translation7);
		root.addChild(tg7);
		Box out7 = new Box(0.4f, 0.1f, 0.4f, primflags, apperOne);
		tg7.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out7.setUserData(translation7);
		tg7.addChild(out7);

		Transform3D translation8 = new Transform3D();
		translation8.setTranslation(new Vector3f(4.0f, -0.1f, -5.5f));
		TransformGroup tg8 = new TransformGroup(translation8);
		root.addChild(tg8);
		Box out8 = new Box(0.4f, 0.1f, 0.4f, primflags, apperOne);
		tg8.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out8.setUserData(translation8);
		tg8.addChild(out8);

		Transform3D translation9 = new Transform3D();
		translation9.setTranslation(new Vector3f(-4.0f, -0.1f, -5.5f));
		TransformGroup tg9 = new TransformGroup(translation9);
		root.addChild(tg9);
		Box out9 = new Box(0.4f, 0.1f, 0.4f, primflags, apperOne);
		tg9.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out9.setUserData(translation9);
		tg9.addChild(out9);
	}

	public void createOut2() {
		Transform3D translation1 = new Transform3D();
		translation1.setTranslation(new Vector3f(0.0f, -0.1f, 5.5f));
		TransformGroup tg1 = new TransformGroup(translation1);
		root.addChild(tg1);
		Box out1 = new Box(0.4f, 0.1f, 0.4f, primflags, apperTwo);
		tg1.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out1.setUserData(translation1);
		tg1.addChild(out1);

		Transform3D translation2 = new Transform3D();
		translation2.setTranslation(new Vector3f(1.0f, -0.1f, 5.5f));
		TransformGroup tg2 = new TransformGroup(translation2);
		root.addChild(tg2);
		Box out2 = new Box(0.4f, 0.1f, 0.4f, primflags, apperTwo);
		tg2.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out2.setUserData(translation2);
		tg2.addChild(out2);

		Transform3D translation3 = new Transform3D();
		translation3.setTranslation(new Vector3f(-1.0f, -0.1f, 5.5f));
		TransformGroup tg3 = new TransformGroup(translation3);
		root.addChild(tg3);
		Box out3 = new Box(0.4f, 0.1f, 0.4f, primflags, apperTwo);
		tg3.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out3.setUserData(translation3);
		tg3.addChild(out3);

		Transform3D translation4 = new Transform3D();
		translation4.setTranslation(new Vector3f(2.0f, -0.1f, 5.5f));
		TransformGroup tg4 = new TransformGroup(translation4);
		root.addChild(tg4);
		Box out4 = new Box(0.4f, 0.1f, 0.4f, primflags, apperTwo);
		tg4.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out4.setUserData(translation4);
		tg4.addChild(out4);

		Transform3D translation5 = new Transform3D();
		translation5.setTranslation(new Vector3f(-2.0f, -0.1f, 5.5f));
		TransformGroup tg5 = new TransformGroup(translation5);
		root.addChild(tg5);
		Box out5 = new Box(0.4f, 0.1f, 0.4f, primflags, apperTwo);
		tg5.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out5.setUserData(translation5);
		tg5.addChild(out5);

		Transform3D translation6 = new Transform3D();
		translation6.setTranslation(new Vector3f(3.0f, -0.1f, 5.5f));
		TransformGroup tg6 = new TransformGroup(translation6);
		root.addChild(tg6);
		Box out6 = new Box(0.4f, 0.1f, 0.4f, primflags, apperTwo);
		tg6.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out6.setUserData(translation6);
		tg6.addChild(out6);

		Transform3D translation7 = new Transform3D();
		translation7.setTranslation(new Vector3f(-3.0f, -0.1f, 5.5f));
		TransformGroup tg7 = new TransformGroup(translation7);
		root.addChild(tg7);
		Box out7 = new Box(0.4f, 0.1f, 0.4f, primflags, apperTwo);
		tg7.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out7.setUserData(translation7);
		tg7.addChild(out7);

		Transform3D translation8 = new Transform3D();
		translation8.setTranslation(new Vector3f(4.0f, -0.1f, 5.5f));
		TransformGroup tg8 = new TransformGroup(translation8);
		root.addChild(tg8);
		Box out8 = new Box(0.4f, 0.1f, 0.4f, primflags, apperTwo);
		tg8.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out8.setUserData(translation8);
		tg8.addChild(out8);

		Transform3D translation9 = new Transform3D();
		translation9.setTranslation(new Vector3f(-4.0f, -0.1f, 5.5f));
		TransformGroup tg9 = new TransformGroup(translation9);
		root.addChild(tg9);
		Box out9 = new Box(0.4f, 0.1f, 0.4f, primflags, apperTwo);
		tg9.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		out9.setUserData(translation9);
		tg9.addChild(out9);
	}

	public void createSwitch() {
		Transform3D translation = new Transform3D();
		translation.rotX(Math.PI / 1.3f);
		translation.setTranslation(new Vector3f(6.0f, -0.2f, 5.5f));
		TransformGroup tgSW = new TransformGroup(translation);
		root.addChild(tgSW);
		Box sw1 = new Box(0.9f, 0.9f, 0.6f, primflags, apperSwitch);
		tgSW.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		sw1.setUserData("SWITCH");
		tgSW.addChild(sw1);

		Transform3D translation2 = new Transform3D();
		translation2.rotX(Math.PI / -1.3f);
		translation2.setTranslation(new Vector3f(-6.0f, -0.2f, -5.5f));
		TransformGroup tgSW2 = new TransformGroup(translation2);
		root.addChild(tgSW2);
		Box sw2 = new Box(0.9f, 0.9f, 0.6f, primflags, apperSwitch);
		tgSW2.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		sw2.setUserData("SWITCH");
		tgSW2.addChild(sw2);
	}
	
////////// BUMP MAPPING	
	private TextureUnitState[] loadTexture(String texname, String dot3Name) {

		Texture CTEX = new TextureLoader(texname, null).getTexture();
		Texture NTEX = new TextureLoader(dot3Name, null).getTexture();
		TextureLoader LM = new TextureLoader(textureLightMapName,null);
		ImageComponent2D LMImage = LM.getImage();
		LMImage.setCapability(ImageComponent2D.ALLOW_IMAGE_WRITE);
		LMImage.setCapability(ImageComponent2D.ALLOW_IMAGE_READ);
		Texture2D TEXLM = new Texture2D(Texture2D.BASE_LEVEL,Texture2D.RGB, LMImage.getWidth(),	LMImage.getHeight());
		TEXLM.setImage(0, LMImage);
		TEXLM.setMagFilter(Texture2D.NICEST);
		TEXLM.setMinFilter(Texture2D.NICEST);
		TEXLM.setCapability(Texture2D.ALLOW_ENABLE_WRITE);
		TEXLM.setCapability(Texture2D.ALLOW_ENABLE_READ);
		TEXLM.setCapability(Texture2D.ALLOW_IMAGE_WRITE);
		TEXLM.setCapability(Texture2D.ALLOW_IMAGE_READ);
		TextureAttributes NTEXATTR = new TextureAttributes();
		TextureAttributes texAttLightMap = new TextureAttributes();
		TextureAttributes TEXATC = new TextureAttributes();
		TEXATC.setTextureMode(TextureAttributes.MODULATE);
		NTEXATTR.setTextureMode(TextureAttributes.COMBINE);
		NTEXATTR.setCombineRgbMode(TextureAttributes.COMBINE_DOT3);
		NTEXATTR.setCombineRgbScale(2);
		TexCoordGeneration TEXGEN = new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR,TexCoordGeneration.TEXTURE_COORDINATE_3);
		TextureUnitState TUL = new TextureUnitState(TEXLM,texAttLightMap, TEXGEN);
		TextureUnitState TUNM = new TextureUnitState(NTEX,NTEXATTR, TEXGEN);
		TextureUnitState TUC = new TextureUnitState(CTEX, TEXATC,TEXGEN);
		TextureUnitState[] TU = new TextureUnitState[3];
		TU[0] = TUL;
		TU[1] = TUNM;
		TU[2] = TUC;
		for (int i = 0; i < TU.length; i++) {
			TU[i].setCapability(TextureUnitState.ALLOW_STATE_WRITE);
			TU[i].setCapability(TextureUnitState.ALLOW_STATE_READ);
		}
		return TU;
	}

	private Appearance createAppearance(String tex, String normalMap) {
		TextureUnitState[] texture = loadTexture(tex, normalMap);
		Appearance apper = new Appearance();
		Material material = new Material();
		material.setAmbientColor(new Color3f(1.0f, 1.0f, 1.0f));
		material.setDiffuseColor(new Color3f(0.5f, 0.5f, 0.5f));
		material.setSpecularColor(new Color3f(0.1f, 0.1f, 0.1f));
		apper.setMaterial(material);
		apper.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_READ);
		apper.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE);
		apper.setCapability(Appearance.ALLOW_TEXTURE_UNIT_STATE_READ);
		apper.setCapability(Appearance.ALLOW_TEXTURE_UNIT_STATE_WRITE);
		PolygonAttributes POLATTR = new PolygonAttributes();
		POLATTR.setCapability(PolygonAttributes.ALLOW_MODE_WRITE);
		POLATTR.setCullFace(PolygonAttributes.CULL_NONE);
		apper.setPolygonAttributes(POLATTR);
		apper.setTextureUnitState(texture);

		return apper;
	}
}